In the field of image recognition, a CNN model is usually adopted to determine a classification of an image to be recognized. Before the classification of the image to be recognized is recognized through the CNN model, the CNN model is required to be trained at first.
Training of a CNN model is usually implemented in a manner as follows. At first, model parameters of the CNN model to be trained are initialized, the model parameters including initial convolution kernels of the respective convolution layer, initial bias matrixes of the respective convolution layer, and an initial weight matrix and an initial bias vector of a fully connected layer. Then, an area to be processed with a fixed height and a fixed width is acquired from each of preselected training images, the fixed height and the fixed width being matched with a classification of an image to be recognized, which is preset, as an image that can be processed, by the CNN model to be trained. The area to be processed corresponding to each of the training images is input into the CNN model to be trained. Next, on each convolution layer, convolution operation and maximal pooling operation are performed on each area to be processed by using the initial convolution kernel and initial bias matrix of each convolution layer, to obtain a feature image of each area to be processed on each convolution layer. Then, each feature image is processed to obtain classification probability of each area to be processed by using the initial weight matrix and initial bias vector of the fully connected layer. Then, a classification error is calculated according to initial classification and the classification probability of each of the training images. A mean of the classification errors is calculated according to the classification errors of all the training images. Then, the model parameters of the CNN model to be trained are regulated by using the mean of the classification errors. Then, the abovementioned respective steps are iterated for a specified number of times by using the regulated model parameters and the respective training images. Finally, model parameters obtained when the number of iterations reaches the specified number of times are determined as the model parameters of the trained CNN model.
In a process of implementing the present disclosure, the inventor finds that a related technology at least has a problem as follows.
It is necessary to acquire the areas to be processed with the fixed height and the fixed width from the pre-selected training images in the process of training a CNN model, and accordingly the trained CNN model can only recognize an image with the fixed height and the fixed width, which may cause certain limits to image recognition of the trained CNN model and further cause a limited application range.